﻿var url = new Url();
var $css = url.GetQueryString("css");

//设置分页信息
var page = new Page();
page.Url = "../Handler/LoanProductOrderHandler.ashx";
page.Dom = $("#searchArea");
page.type = 0;
page.CallBack = function (data) {
    $(".contractInfo").empty();
    $.each(data, function (index, item) {
        item.Css = $css;
        item.Allow = item.Allow ? "inline" : "none";
        item.ContractReview = item.ContractReview ? "inline" : "none";
        $("#ContractTemplete").tmpl(item).appendTo($(".contractInfo"));
        //if (item.Allow) {
        //    item.ContractReview = item.ContractReview ? "inline" : "none";
        //    $("#ContractTemplete").tmpl(item).appendTo($(".contractInfo"));
        //} else {
        //    $("#ContractTemplete").tmpl(item).appendTo($(".contractInfo")).find(".verify").remove();
        //}
    });
};

page.GetPageData();

//搜索用户
$(".btnSearchBorrow").bind("click", function () {
    var $userName = $(".txtName").val();
    var $phone = $(".txtPhone").val();
    $.getJSON("../Handler/LoanUserInfo.ashx",
       { UserName: $userName, Phone: $phone, BusinessMan: true, type: 8, _: Math.random() },
        function (result) {
            if (result.Status) {
                $(".userInfo").empty();
                $("#UserTemplete").tmpl(result.Data).appendTo($(".userInfo"));
                $(".userInfo tr").css("cursor", "pointer").click(function () {
                    $(".txtuserName").val($(this).find(".name").text());
                    $(".txtUserId").val($(this).find(".userId").text());
                });
            }
        });
});

$(".btnDelLender").bind("click", function () {
    $(".txtuserName").val("");
    $(".txtUserId").val("");
});


$(".btnShow").bind("click", function () {
    $(".txtName").val($(".txtUserName").val());
})

$(".txtuserName").bind("click", function () {
    $(".btnShow").click();
});
